package com.wnd.dell.myapplication;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


public class FoodAdapter extends BaseAdapter {
    private Context mContext2;
    private FoodDate foodDate;
    public FoodAdapter(Context context) {this.mContext2 = context;}
    public void setData(FoodDate foodDate) {
        this.foodDate = foodDate;
        this.notifyDataSetChanged();
    }
    @Override
    public int getCount() {
        if (foodDate == null) {
            return 0;
        } else {
            return foodDate.getResult().getData().size();
        }
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        System.out.println("getView " + position + " " + convertView);
        FoodAdapter.ViewHolder111 holder = null;
        if (convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(mContext2);
            convertView = inflater.inflate(R.layout.item3_layout, null);
            holder = new FoodAdapter.ViewHolder111();
            holder.textView = (TextView) convertView.findViewById(R.id.tv_id3);
            holder.textView2 = (TextView) convertView.findViewById(R.id.tv_Title3);
            holder.textView3 = (TextView) convertView.findViewById(R.id.tv_Tags3);
            holder.textView4 = (TextView) convertView.findViewById(R.id.tv_Ingredients3);
            holder.textView5 = (TextView) convertView.findViewById(R.id.tv_Burden3);
            holder.textView6 = (TextView) convertView.findViewById(R.id.tv_Imtro3);
            holder.imageView = (ImageView) convertView.findViewById(R.id.iv_head);
            convertView.setTag(holder);
        } else {
            holder = (FoodAdapter.ViewHolder111) convertView.getTag();
        }
        holder.textView.setText(foodDate.getResult().getData().get(position).getId());
        holder.textView2.setText(foodDate.getResult().getData().get(position).getTitle());
        holder.textView3.setText(foodDate.getResult().getData().get(position).getTags());
        holder.textView4.setText(foodDate.getResult().getData().get(position).getIngredients());
        holder.textView5.setText(foodDate.getResult().getData().get(position).getBurden());
        holder.textView6.setText(foodDate.getResult().getData().get(position).getImtro());
        return convertView;

    }

    public static class ViewHolder111 {
        public TextView textView;
        public TextView textView2;
        public TextView textView3;
        public TextView textView4;
        public TextView textView5;
        public TextView textView6;
        public ImageView imageView;
    }
}
